﻿using InteControlSys.VehicleControlService;
using Microsoft.Expression.Interactivity.Core;
using PropertyTools.Wpf;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace InteControlSys.ViewModel
{
    public class NoRecordViewModel:NodeViewModel
    {
        public NoRecordViewModel(string name, MainWindowViewModel root,int truck,int statusId)
        {
            this.Name = name;
            this.Parent = null;
            this.RootVM = root;
            this.IsExpanded = true;
            this.NodeType = "NoRecordViewModel";
            this.TruckCount = truck;
            this.StatusID = statusId;
            this.OperatingTruckList = new ObservableCollection<NodeViewModel>();

        }

        public override Uri GetMyIcon()
        {
            return null;
        }
        public override void ExecuteConfirmCommand(object parameter)
        {
            List<NodeViewModel> selItems = OperatingTruckList.Where(x => x.IsSelected).ToList();

        }

        //private UnknownVehicleInfo unknownVehicle;

        //public UnknownVehicleInfo UnknownVehicle
        //{
        //    get { return unknownVehicle; }
        //    set
        //    {
        //        unknownVehicle = value;
        //        NotifyChanged("UnknownVehicle");
        //    }
        //}


        private UnnknownNodeViewModel unknownNode;
        public UnnknownNodeViewModel UnknownNode
        {
            get { return unknownNode; }
            set
            {
                unknownNode = value;
                NotifyChanged("UnknownNode");
            }
        }

        private string correctLicense;
        public string CorrectLicense
        {
            get { return correctLicense; }
            set
            {
                correctLicense = value;
                NotifyChanged("CorrectLicense");
            }
        }

        private string _errorMSG = null;
        public string ErrorMSG
        {
            get { return _errorMSG; }
            set
            {
                _errorMSG = value;
                NotifyChanged("ErrorMSG");
            }
        }

        public ICommand SolveError
        {
            get
            {
                return new DelegateCommand(() =>
                {
                    this.CorrectLicense = correctLicense;
                    var result=MainWindowViewModel.ControlService.SolveRecognitionError(this.CorrectLicense, this.UnknownNode.ID, MainWindow.OperateNo);
                    if (result.Success)
                    {
                        ErrorMSG = "已修改车牌号为" + CorrectLicense;
                    }
                    else
                        ErrorMSG = result.ErrorMessage;
                });
            }
        }
    }
}
